<template>
	<el-drawer size="90%" :show-close="false" :title="title" :before-close="closeDrawer"   :close-on-click-modal="false" top="50px" center :visible.sync="dialogFormVisible">
		<avue-form ref="form" v-model="obj" :disabled="isView" :option="option" @submit="submit" style="padding-bottom: 50px;">
			<template slot-scope="" slot="storeLogoUrl">
				<img :src="obj.storeLogoUrl" style="width:150px;height:150px;border: 2px #DEDEDE solid;" />
			</template>
			<template slot-scope="" slot="registerTime">
				<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.registerTime }}</el-tag>
			</template>
			<template slot-scope="" slot="tripartiteStoreId">
				<el-tag color="#fff" style="border: none;color: #333333;">{{ obj.tripartiteStoreId }}</el-tag>
			</template>
			<template slot-scope="" slot="goodsClassIds">
				<el-select
					v-model="obj.goodsClassIdsLabel"
					size="mini"
					placeholder="请选择"
					multiple
					collapse-tags
					@remove-tag="goodsClassRemove"
				>
					<el-option :value="goodsClassIdsValue" style="height: auto">
						<el-tree
							:data="goodsClassIdsOptions"
							:default-expanded-keys="[]"
							show-checkbox
							node-key="id"
							accordion
							ref="goodsClassTree"
							highlight-current
							:props="propsClass"
							@check="goodsClassIdsCheckChange"
						></el-tree>
					</el-option>
				</el-select>
			</template>
			<template slot-scope="" slot="operatingAreas">
				<el-select
					v-model="obj.operatingAreas"
					size="mini"
					placeholder="请选择"
					multiple
					collapse-tags
					@remove-tag="signRemove"
				>
					<el-option :value="signMineStatusValue" style="height: auto">
						<el-tree
							:data="signOptions"
							:default-expanded-keys="[]"
							show-checkbox
							node-key="id"
							accordion
							ref="signTree"
							highlight-current
							:props="props1"
							@check="signHandleCheckChange"
						></el-tree>
					</el-option>
				</el-select>
			</template>
			<template slot-scope="" slot="businessTerm">
				<div class="upload">
					<el-date-picker
						v-model="obj.acTime"
						type="daterange"
						size="mini"
						:disabled="isView"
						range-separator="至"
						start-placeholder="营业开始日期"
						end-placeholder="营业结束日期"
						align="right"
						format="yyyy-MM-dd"
						value-format="yyyy-MM-dd"
					></el-date-picker>
				</div>
			</template>
			<template slot-scope="scope" slot="businessLicense">
				<div>
					<el-upload
						class="avatar-uploader"
						:action="upImgUrl"
						:disabled="isView"
						:headers="headers"
						list-type="picture-card"
						:show-file-list="false"
						:on-success="businessLicenseSuccess"
						:before-upload="beforeStoreLogoUrlUpload"
					>
						<img v-if="obj.businessLicense" :src="obj.businessLicense" class="avatar" />
						<i v-else class="el-icon-plus avatar-uploader-icon"></i>
					</el-upload>
					<div style="padding: 0.2rem; font-size: 0.24rem;color: #999;width: 148px;text-align: center;">
						<span style="color: red">*</span>
						营业执照
						<span v-if="obj.businessLicense"  style="color: #F39800;cursor:pointer;" @click="showBigPic(obj.businessLicense,'营业执照')">查看</span>
					</div>
				</div>
			</template>
			<template slot-scope="scope" slot="operateLicenseImg">
				<div>
					<el-upload
						class="avatar-uploader"
						:action="upImgUrl"
						:headers="headers"
						:disabled="isView"
						list-type="picture-card"
						:show-file-list="false"
						:on-success="operateLicenseImgSuccess"
						:before-upload="beforeStoreLogoUrlUpload"
					>
						<div v-if="obj.operateLicenseImg" class="business-license">
							<span @click.stop="deleteImg" class="el-icon-close"></span>
							<img :src="obj.operateLicenseImg" class="avatar" />
						</div>
						<i v-else class="el-icon-plus avatar-uploader-icon"></i>
					</el-upload>
					<div style="padding: 0.2rem; font-size: 0.24rem;color: #999;width: 148px;text-align: center;">经营许可证
						<span v-if="obj.operateLicenseImg"  style="color: #F39800;cursor:pointer;" @click="showBigPic(obj.operateLicenseImg,'经营许可证')">查看</span>
					</div>
				</div>
			</template>
			<template slot-scope="scope" slot="frontcardImg">
				<div>
					<el-upload
						class="avatar-uploader"
						:action="upImgUrl"
						:headers="headers"
						:disabled="isView"
						list-type="picture-card"
						:show-file-list="false"
						:on-success="frontcardImgSuccess"
						:before-upload="beforeStoreLogoUrlUpload"
					>
						<img v-if="obj.frontcardImg" :src="obj.frontcardImg" class="avatar" />
						<i v-else class="el-icon-plus avatar-uploader-icon"></i>
					</el-upload>
					<div style="padding: 0.2rem; font-size: 0.24rem;color: #999;width: 148px;text-align: center;">
						<span style="color: red">*</span>
						身份证正面
						<span v-if="obj.frontcardImg"  style="color: #F39800;cursor:pointer;" @click="showBigPic(obj.frontcardImg,'身份证正面')">查看</span>
					</div>
				</div>
			</template>
			<template slot-scope="scope" slot="backcardImg">
				<div>
					<el-upload
						class="avatar-uploader"
						:action="upImgUrl"
						list-type="picture-card"
						:disabled="isView"
						:headers="headers"
						:show-file-list="false"
						:on-success="backcardImgSuccess"
						:before-upload="beforeStoreLogoUrlUpload"
					>
						<img v-if="obj.backcardImg" :src="obj.backcardImg" class="avatar" />
						<i v-else class="el-icon-plus avatar-uploader-icon"></i>
					</el-upload>
					<div style="padding: 0.2rem; font-size: 0.24rem;color: #999;width: 148px;text-align: center;">
						<span style="color: red">*</span>
						身份证反面
						<span v-if="obj.backcardImg"  style="color: #F39800;cursor:pointer;" @click="showBigPic(obj.backcardImg,'身份证反面')">查看</span>
					</div>
				</div>
			</template>

			<template slot-scope="scope" slot="orthersImgs">
				<div class="others">
					<div class="other-item">
						<el-upload
							class="avatar-uploader"
							:action="upImgUrl"
							list-type="picture-card"
							:disabled="isView"
							:headers="headers"
							:show-file-list="false"
							:on-success="otherOneImgSuccess"
							:before-upload="beforeStoreLogoUrlUpload"
						>
							<div v-if="obj.otherOne" class="business-license">
								<span @click.stop="deleteImgOne" class="el-icon-close"></span>
								<img  :src="obj.otherOne" class="avatar" />
							</div>
							<i v-else class="el-icon-plus avatar-uploader-icon"></i>
						</el-upload>
						<div style="padding: 0.2rem; font-size: 0.24rem;color: #999;width: 148px;text-align: center;">其他证件（1）
							<span v-if="obj.otherOne"  style="color: #F39800;cursor:pointer;" @click="showBigPic(obj.otherOne,'其他证件（1）')">查看</span>
						</div>
					</div>
					<div class="other-item" v-if="obj.otherOne">
						<el-upload
							class="avatar-uploader"
							:action="upImgUrl"
							list-type="picture-card"
							:disabled="isView"
							:headers="headers"
							:show-file-list="false"
							:on-success="otherTwoImgSuccess"
							:before-upload="beforeStoreLogoUrlUpload"
						>

							<div v-if="obj.otherTwo" class="business-license">
								<span @click.stop="deleteImgTwo" class="el-icon-close"></span>
								<img :src="obj.otherTwo" class="avatar" />
							</div>
							<i v-else class="el-icon-plus avatar-uploader-icon"></i>
						</el-upload>
						<div style="padding: 0.2rem; font-size: 0.24rem;color: #999;width: 148px;text-align: center;">其他证件（2）
							<span v-if="obj.otherTwo"  style="color: #F39800;cursor:pointer;" @click="showBigPic(obj.otherTwo,'其他证件（2）')">查看</span>
						</div>
					</div>
					<div class="other-item" v-if="obj.otherTwo">
						<el-upload
							class="avatar-uploader"
							:action="upImgUrl"
							list-type="picture-card"
							:disabled="isView"
							:headers="headers"
							:show-file-list="false"
							:on-success="otherThreeImgSuccess"
							:before-upload="beforeStoreLogoUrlUpload"
						>

							<div v-if="obj.otherThree" class="business-license">
								<span @click.stop="deleteImgThree" class="el-icon-close"></span>
								<img :src="obj.otherThree" class="avatar" />
							</div>
							<i v-else class="el-icon-plus avatar-uploader-icon"></i>
						</el-upload>
						<div style="padding: 0.2rem; font-size: 0.24rem;color: #999;width: 148px;text-align: center;">其他证件（3）
							<span v-if="obj.otherThree"  style="color: #F39800;cursor:pointer;" @click="showBigPic(obj.otherThree,'其他证件（3）')">查看</span>
						</div>
					</div>
					<div class="other-item" v-if="obj.otherThree">
						<el-upload
							class="avatar-uploader"
							:action="upImgUrl"
							list-type="picture-card"
							:disabled="isView"
							:headers="headers"
							:show-file-list="false"
							:on-success="otherFourImgSuccess"
							:before-upload="beforeStoreLogoUrlUpload"
						>

							<div v-if="obj.otherFour" class="business-license">
								<span @click.stop="deleteImgFour" class="el-icon-close"></span>
								<img :src="obj.otherFour" class="avatar" />
							</div>
							<i v-else class="el-icon-plus avatar-uploader-icon"></i>
						</el-upload>
						<div style="padding: 0.2rem; font-size: 0.24rem;color: #999;width: 148px;text-align: center;">其他证件（4）
							<span v-if="obj.otherFour"  style="color: #F39800;cursor:pointer;" @click="showBigPic(obj.otherFour,'其他证件（4）')">查看</span>
						</div>
					</div>
					<div class="other-item" v-if="obj.otherFour">
						<el-upload
							class="avatar-uploader"
							:action="upImgUrl"
							list-type="picture-card"
							:disabled="isView"
							:headers="headers"
							:show-file-list="false"
							:on-success="otherFiveImgSuccess"
							:before-upload="beforeStoreLogoUrlUpload"
						>
							<div v-if="obj.otherFive" class="business-license">
								<span @click.stop="deleteImgFive" class="el-icon-close"></span>
								<img :src="obj.otherFive" class="avatar" />
							</div>
							<i v-else class="el-icon-plus avatar-uploader-icon"></i>
						</el-upload>
						<div style="padding: 0.2rem; font-size: 0.24rem;color: #999;width: 148px;text-align: center;">其他证件（5）
							<span v-if="obj.otherFive"  style="color: #F39800;cursor:pointer;" @click="showBigPic(obj.otherFive,'其他证件（5）')">查看</span>
						</div>
					</div>
				</div>
			</template>
			<template slot-scope="scope" slot="banner">
				<div>
					<div class="upload" v-for="(item, index) in obj.banner" :key="index">
						<el-input style="margin-right: 0.2rem;width: 70%;" v-model="item.imgUrl" :clearable="true" :readonly="true" />
						<el-image :preview-src-list="srcList" fit="contain" :src="item.imgUrl" style="margin-right: 0.2rem;width: 50px; height: 50px"></el-image>
					</div>
				</div>
			</template>
			<template slot-scope="scope" slot="noTime">
				<div class="upload">
					<el-date-picker
						v-model="obj.noTime"
						type="daterange"
						size="mini"
						:disabled="isView"
						@change="clearnoTime"
						range-separator="至"
						start-placeholder="开始日期"
						end-placeholder="结束日期"
						align="right"
						format="yyyy-MM-dd"
						value-format="yyyy-MM-dd"
					></el-date-picker>
				</div>
			</template>
			<template slot-scope="scope" slot="noActivity">
				<div class="upload">
					<el-date-picker
						v-model="obj.noActivity"
						type="daterange"
						size="mini"
						:disabled="isView"
						@change="clearnoActivity"
						range-separator="至"
						start-placeholder="开始日期"
						end-placeholder="结束日期"
						align="right"
						format="yyyy-MM-dd"
						value-format="yyyy-MM-dd"
					></el-date-picker>
				</div>
			</template>

			<template slot-scope="scope" slot="validity">
				<div>
					<el-date-picker
						v-model="obj.validity"
						:picker-options="pickerOptions"
						type="date"
						size="mini"
						:disabled="isView"
						format="yyyy-MM-dd"
						value-format="yyyy-MM-dd"
						placeholder="选择日期"
					></el-date-picker>
				</div>
			</template>

			<template slot-scope="scope" slot="menuForm">
				<el-button @click="closeDrawer" v-if="!isView">取消</el-button>
				<el-button @click="closeDrawer" v-else>关闭</el-button>
			</template>
		</avue-form>
		<el-dialog width="30%" :title="workImg.name" :visible.sync="innerVisible" append-to-body center>
			<img align="center" style="width: 60%;height: auto;margin-left: 20%;" :src="workImg.imgUrl" />
		</el-dialog>
		<!-- <sel-file ref="selFile" @callback="selFileCallBack" albumCode="store" dialogTitle="选择图片" selectType="radio" selMaxWidth="300px" selMaxHeight="300px"></sel-file> -->
	</el-drawer>
</template>

<script>
import selFile from '@/components/file/selFile';
import { getParentAndGrandInfoById, getParentInfoById, getListTree,
// getAllChanelMapList,
getStoreDetail, getStoreBanner,getClassTree,getMapAllGoodsClass,listTreeByUserOrganization } from '@/api/base/store/store';
import { getToken } from '@/util/store';
import { checkTel, zipCode,isContractNo } from '@/util/rej';
import { onlyDateFormat } from '@/util/date';
import { testCommissionRate, validateCreditCode, validateChineseEnglish } from '@/util/util';
import { getOrganizationMapByLevel } from '@/api/base/goods/addGoods';

export const isEmail = (rule, value, callback) => {
	let re = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/
	let flag = false;
	flag = re.test(value)
	if (!value) {
		callback();
	} else if (!flag) {
		callback(new Error("邮箱格式不正确"))
	} else {
		callback();
	}
}
export function validateNum(rule,value,callback) {
	if(!value){
		callback();
	}
	setTimeout(() => {
		const re = /^[0-9]+$/;
		const rsCheck = re.test(value);
		if (!rsCheck) {
			callback(new Error('只能输入数字'));
		}else {
			callback();
		}
	}, 0);
}
var validateTrueName = (rule, value, callback) => {
	if (value === '') {
		callback(new Error('请输入店主姓名'));
	} else if (!/^([\u4E00-\uFA29]|[\uE7C7-\uE7F3]|[a-zA-Z0-9_-]){2,8}$/.test(value)) {
		callback(new Error('姓名应为2-8个中文、英文、数字'));
	} else {
		callback();
	}
};
var validateAccount = (rule, value, callback) => {
	if (value === '') {
		callback(new Error('请输入店铺账号'));
	} else if (!/^([a-zA-Z0-9]){1,16}$/.test(value)) {
		callback(new Error('店铺账号应为1-16个英文、数字'));
	} else {
		callback();
	}
};
var validateCompanyName = (rule, value, callback) => {
	if (value === '') {
		callback(new Error('请输入公司名称'));
	} else if (!/^[\u4E00-\u9FA5A-Za-z0-9]+$/.test(value)) {
		callback(new Error('公司名称必须为2-30位的中文，字母或数字'));
	} else if (value.length < 2 || value.length > 30) {
		callback(new Error('公司名称必须为2-30位的中文，字母或数字'));
	} else {
		callback();
	}
};
var validateBusinessCode = (rule, value, callback) => {
	if (value === '') {
		callback(new Error('请输入营业执照号'));
	} else if (!/^[0-9]{15,20}$/.test(value)) {
		callback(new Error('营业执照号必须是为15-20位的数字'));
	} else {
		callback();
	}
};
var validateMonths = (rule, value, callback) => {
	if (value === '') {
		callback(new Error('请输入每几月一结'));
	} else if (!/^[0-9]*$/.test(value)) {
		callback(new Error('请输入正整数'));
	} else if (value < 1) {
		callback(new Error('至少每1月一结'));
	} else {
		callback();
	}
};
var validateDay = (rule, value, callback) => {
	if (value === '') {
		callback(new Error('请输入几号结算'));
	} else if (!/^[0-9]*$/.test(value)) {
		callback(new Error('请输入正整数'));
	} else if (value < 1 || value > 29) {
		callback(new Error('1-29号可结算'));
	} else {
		callback();
	}
};
var validateWeeksDay = (rule, value, callback) => {
	if (value === '') {
		callback(new Error('请输入周几结算'));
	} else if (!/^[1-7]$/.test(value)) {
		callback(new Error('请输入1-7的正整数'));
	} else if (value < 1 || value > 7) {
		callback(new Error('周一到周日可结算'));
	} else {
		callback();
	}
};
export const isTelephone = (rule, value, callback) => {
	let re = /^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/
	let flag = false;
	flag = re.test(value)
	if (!value) {
		callback(new Error("请输入手机号码"));
	} else if (!flag) {
		callback(new Error("手机号码不正确"))
	} else {
		callback();
	}
};
var Dict = JSON.parse(localStorage.getItem('mall-dictionary')).content;
var baseUrl = '/base/area/getAreaListByLevel';
export default {
	name: 'storeDetail',
	props: {
		isView: {
			//是否查看
			type: Boolean,
			default() {
				return true;
			}
		},
		isActivity: {
			//是否活动查看
			type: Boolean,
			default() {
				return false;
			}
		},
		dialogFormVisible: {
			//弹框是否打开
			type: Boolean,
			default() {
				return false;
			}
		},
		title: {
			//弹框标题
			type: String,
			default() {
				return '店铺管理';
			}
		},
		storeId: {
			type: String
		}
	},
	data() {
		return {
			innerVisible:false,
			workImg:{},
			pickerOptions: {
				disabledDate(time) {
					return time.getTime() + 3600 * 1000 * 24 * 1 < Date.now();
				}
			},
			srcList: [],
			orthersImg: false,
			upImgUrl: `/res/album/sys_img_upload?album_code=pic_user_photo`,
			headers: {},
			obj: {
			},
			goodsClassDict: [], //商品分类
			imgType: 0, //四张资质图片从1开始
			isAddOption: 0, // 1 新增 0 查看或编辑
			option: {
				card: true,
				size: 'mini',
				mock: false,
				submitBtn: this.isView ? false : true,
				emptyBtn: false,
				menuBtn: true,
				menuPostion: 'right',
				labelWidth: '130',
				group: [
					{
						label: '店铺logo',
						icon: 'el-icon-info',
						prop: 'group1',
						display:false,
						column: [
							{
								prop: 'storeLogoUrl',
								formslot: true
							}
						]
					},
					{
						label: '店铺信息',
						icon: 'el-icon-info',
						prop: 'group2',
						column: [
							{
								label: '店铺账号',
								prop: 'storeAccount',
								disabled:false ,
								type:'input',
								span: 8,
								fixed: true,
								maxlength: 16,
								showWordLimit: true,
								rules: [
									{
										required: true,
										validator: validateAccount,
										trigger: 'blur'
									}
								]
							},
							{
								label: '商家公司名称',
								prop: 'companyName',
								maxlength: 30,
								showWordLimit: true,
								span: 8,
								cell: true,
								rules: [
									{
										required: true,
										validator: validateCompanyName,
										trigger: 'blur'
									}
								]
							},
							{
								label: '店铺名称',
								prop: 'storeName',
								maxlength: 12,
								showWordLimit: true,
								span: 8,
								rules: [
									{
										required: true,
										message: '请输入店铺名称',
										trigger: 'blur'
									}
								]
							},
							{
								label: '营业执照号',
								prop: 'businessNo',
								maxlength: 20,
								showWordLimit: true,
								display:false,
								span: 8,
								cell: true,
								rules: [
									{
										required: true,
										validator: validateBusinessCode,
										trigger: 'blur'
									}
								]
							},
							{
								label: '营业执照有效期',
								prop: 'businessTerm',
								type: 'daterange',
								formslot: true,
								span: 8,
								rules: [
									{
										required: true,
										message: '请选择营业执照有效期',
										trigger: 'change'
									}
								]
							},
							{
								label: '店铺类型',
								prop: 'storeType',
								type: 'select',
								span: 8,
								dicData: [
									{
										label: '自营',
										value: 0
									},
									{
										label: '非自营',
										value: 1
									}
								],
								rules: [
									{
										required: true,
										message: '请选择店铺类型',
										trigger: 'blur'
									}
								]
							},
							{
								label: '经营品类',
								prop: 'goodsClassIds',
								// value: 'goodsClassIds',
								// type: 'tree',
								// dicUrl: '/base/goodsClass/listTree',
								// multiple: true,
								// showSllLevels:true,
								// props: {
								// 	label: 'className',
								// 	value: 'id',
								// 	children: 'childrenNodes'
								// },
								span: 8,
								formslot: true,
								rules: [
									{
										required: true,
										message: '请选择店铺所属商品分类',
										trigger: 'change'
									}
								],
							},
							{
								label: '统一社会信用代码',
								prop: 'taxNo',
								maxlength: 18,
								showWordLimit: true,
								labelWidth:140,
								span: 8,
								rules: [
									{
										required: true,
										message: '请输入统一社会信用代码',
										trigger: 'blur'
									},
									{
										validator: validateCreditCode,
										trigger: 'blur'
									}
								]
							},
							{
								label: '结算周期',
								prop: 'cycleType',
								type: 'select',
								span: 8,
								tip:'',
								rules: [
									{
										required: true,
										message: '请选择结算周期',
										trigger: 'blur'
									}
								],
								dicData:Dict.settlementCycleTypeEnum,
							},
							{
								label: '每几月一结',
								prop: 'monthsOrWeeks',
								span: 8,
								display: false,
								rules: [
									{
										required: true,
										validator: validateMonths,
										trigger: 'blur'
									}
								]
							},
							{
								label: '几号结算',
								prop: 'day',
								span: 8,
								display: false,
								rules: [
									{
										required: true,
										validator: validateDay,
										trigger: 'blur'
									}
								]
							},
							{
								label: '每几周一结',
								prop: 'monthsOrWeeks',
								type: 'radio',
								span: 8,
								display: false,
								dicData: [
									{
										label: '单周',
										value: 1
									},
									{
										label: '双周',
										value: 2
									}
								],
								rules: [
									{
										required: true,
										message: '请选择每几周一结',
										trigger: 'blur'
									}
								]
							},
							{
								label: '周几结算',
								prop: 'day',
								display: false,
								span: 8,
								rules: [
									{
										required: true,
										validator: validateWeeksDay,
										trigger: 'blur'
									}
								]
							},
							{
								label: '签约区域',
								prop: 'signingAreas',
								value: 'signingAreas',
								type: 'tree',
								defaultExpandAll:false,
								disabled:false,
								dicUrl: '/base/organization/listTreeByUserOrganization',
								// dicData: [],
								props: {
									label: 'name',
									value: 'id',
									children: 'childrenNodes'
								},
								span: 8,
								rules: [
									{
										required: true,
										message: '请选择签约区域',
										trigger: 'change'
									}
								]
							},
							{
								label: '可见区域',
								prop: 'operatingAreas',
								span: 8,
								formslot: true,
								rules: [
									{
										required: true,
										message: '请选择可见区域',
										trigger: 'change'
									}
								]
							},
							{
								label: '店铺客服电话',
								prop: 'kfTelephone',
								span: 8,
								rules: [
									{
										required: true,
										validator: isTelephone,
										trigger: 'blur'
									}
								]
							},
							{
								label: '店铺ID',
								prop: 'tripartiteStoreId',
								formslot: true,
								span: 8
							},
							{
								label: '合同编号',
								prop: 'contractNo',
								span: 8,
								tip: '多个合同中间以","分隔',
								rules: [
									{
										required: true,
										message: '请输入合同编号',
										trigger: 'blur'
									},{
										validator: isContractNo,
										trigger: 'blur'
									}
								]
							},
							{
								label: '抽佣比例',
								disabled: this.isView,
								display:!this.isActivity,
								type: 'input',
								tip: '最大值是1，最小值0.01,例:0.01代表1%',
								precision: 2,
								span: 8,
								minRows: 1,
								maxRows: 1,
								prop: 'commissionRate',
								rules: [
									{
										validator: testCommissionRate,
										trigger: 'blur'
									}
								]
							},
							{
								label: '店铺标签',
								prop: 'storeLabel',
								type: 'select',
								span: 8,
								rules: [
									{
										required: false,
										message: '请选择店铺标签',
										trigger: 'blur'
									}
								],
								dicUrl: '/api/dict/listDictsByCode?dictTypeCode=STORE_LABEL',
								dicMethod: 'post',
								props: {
									label: 'name',
									value: 'dictId'
								}
							},
							{
								label: '对接人电话',
								prop: 'dockingPeoplePhone',
								span: 8,
								display: true,
								rules: [
									{
										validator: checkTel,
										trigger: 'blur'
									}
								]
							},
							{
								label: '支付渠道',
								prop: 'payChannelId',
								span: 8,
								type: 'select',
								dicUrl: '/base/payChannel/getAllChanelMapList',
								filterable:true,
								props: {
									label: 'channelName',
									value: 'id'
								},
								rules: [
									{
										required: true,
										message: '请选择支付渠道',
										trigger: 'change'
									}
								]
							}
						]
					},
					{
						label: '对接人信息',
						icon: 'el-icon-info',
						prop: 'group2',
						display: true,
						column: [
							{
								label: '对接人姓名',
								prop: 'dockingPeopleName',
								span: 8,
								rules: [
									{
										required: true,
										validator: validateTrueName,
										trigger: 'blur'
									}
								]
							},
							{
								label: '对接人电话',
								prop: 'dockingPeoplePhone',
								span: 8,
								rules: [
									{
										required: true,
										validator: checkTel,
										trigger: 'blur'
									}
								]
							},
							{
								label: '对接人邮箱',
								prop: 'dockingPeopleEmail',
								span: 8,
								rules: [
									{
										required: false,
										validator: isEmail,
										trigger: 'blur'
									}
								]
							},
							{
								label: '备用对接人姓名',
								prop: 'dockingPeopleNames',
								span: 8,
								rules: [
									{
										required: true,
										validator: validateTrueName,
										trigger: 'blur'
									}
								]
							},
							{
								label: '备用对接人电话',
								prop: 'dockingPeoplePhones',
								span: 8,
								rules: [
									{
										required: true,
										validator: checkTel,
										trigger: 'blur'
									}
								]
							},
							{
								label: '备用对接人邮箱',
								prop: 'dockingPeopleEmails',
								span: 8,
								rules: [
									{
										validator: isEmail,
										trigger: 'blur'
									}
								]
							}
						]
					},
					{
						label: '办公地址',
						icon: 'el-icon-info',
						prop: 'group4',
						display: true,
						column: [
							{
								label: '省份',
								prop: 'companyProvince',
								type: 'select',
								span: 8,
								props: {
									label: 'area_name',
									value: 'id'
								},
								cascaderItem: ['companyCity', 'companyAreaId'],
								cascaderChange: true,
								dicUrl: `${baseUrl}?level=0`,
								rules: [
									{
										required: true,
										message: '请选择省份',
										trigger: 'change'
									}
								]
							},
							{
								label: '城市',
								prop: 'companyCity',
								type: 'select',
								span: 8,
								props: {
									label: 'area_name',
									value: 'id'
								},
								defaultIndex: 0,
								dicFlag: false,
								dicUrl: `${baseUrl}?parentId={{key}}&&level=1`,
								rules: [
									{
										required: true,
										message: '请选择城市',
										trigger: 'change'
									}
								]
							},
							{
								label: '地区',
								prop: 'companyAreaId',
								type: 'select',
								span: 8,
								row: true,
								props: {
									label: 'area_name',
									value: 'id'
								},
								defaultIndex: 0,
								dicFlag: false,
								dicUrl: `${baseUrl}?parentId={{key}}&&level=2`,
								rules: [
									{
										required: true,
										message: '请选择地区',
										trigger: 'change'
									}
								]
							},
							{
								label: '详细地址',
								prop: 'companyAreaInfo',
								type: 'textarea',
								maxlength:100,
								showWordLimit: true,
								span: 24,
								row: true,
								rules: [
									{
										required: true,
										message: '请输入详细地址',
										trigger: 'blur'
									}
								]
							},
							{
								label: '邮政编码',
								prop: 'companyZip',
								maxlength: 6,
								span: 8,
								rules: [
									{
										required: true,
										validator: zipCode,
										trigger: 'blur'
									}
								]
							}
						]
					},
					{
						label: '资质信息',
						icon: 'el-icon-info',
						prop: 'group3',
						display: true,
						labelWidth:80,
						column: [
							{
								span: 6,
								prop: 'businessLicense',
								formslot: true,
								rules: [
									{
										required: true,
										message: '请上传营业执照',
										trigger: 'blur'
									}
								]
							},
							{
								span: 6,
								prop: 'operateLicenseImg',
								formslot: true
							},
							{
								span: 6,
								prop: 'frontcardImg',
								formslot: true,
								rules: [
									{
										required: true,
										message: '请上传身份证正面',
										trigger: 'blur'
									}
								]
							},
							{
								span: 6,

								prop: 'backcardImg',
								formslot: true,
								rules: [
									{
										required: true,
										message: '请上传身份证反面',
										trigger: 'blur'
									}
								]
							},
							{
								span: 24,
								prop: 'orthersImgs',
								formslot: true,
								label: '其他证件'
							}
						]
					},
					{
						label: '合作周期',
						icon: 'el-icon-info',
						prop: 'group5',
						display: true,
						column: [
							{
								label: '合作周期',
								prop: 'validity',
								type: 'date',
								span: 8,
								formslot: true,
								format: 'yyyy-MM-dd',
								valueFormat: 'yyyy-MM-dd',
								tip: '临到期时三十天，平台给商家和签约人发系统消息',
								rules: [
									{
										required: true,
										message: '请选择合作周期',
										trigger: 'change'
									}
								]
							}
						]
					},
					{
						label: '注册时间',
						icon: 'el-icon-info',
						prop: 'group6',
						display: true,
						column: [
							{
								label: '注册时间',
								readonly: true,
								formslot: true,
								prop: 'registerTime',
								span: 8
							}
						]
					},
					{
						label: '银行账户',
						icon: 'el-icon-info',
						prop: 'group7',
						display: !this.isActivity,
						labelWidth: '120',
						column: [
							{
								label: '银行名称',
								prop: 'bankId',
								type: 'tree',
								span: 8,
								dicUrl: '/base/bank/list',
								props: {
									label: 'bankName',
									value: 'id'
								}
							},
							{
								label: '收款户名',
								prop: 'accountName',
								maxlength: 6,
								span: 8,
								rules: [
									{
										validator: validateChineseEnglish,
										trigger: 'blur'
									}
								]
							},
							{
								label: '收款账号',
								prop: 'accountNum',
								maxlength: 19,
								span: 8,
								rules: [
									{
										validator: validateNum,
										trigger: 'blur'
									}
								]
							}
							// {
							// 	label: '银行所在省份',
							// 	prop: 'bankProvince',
							// 	type: 'select',
							// 	span: 8,
							// 	props: {
							// 		label: 'area_name',
							// 		value: 'id'
							// 	},
							// 	cascaderItem: ['bankCity'],
							// 	cascaderChange: true,
							// 	dicUrl: `${baseUrl}?level=0`
							// },
							// {
							// 	label: '银行所在城市',
							// 	prop: 'bankCity',
							// 	type: 'select',
							// 	span: 8,
							// 	props: {
							// 		label: 'area_name',
							// 		value: 'id'
							// 	},
							// 	dicUrl: `${baseUrl}?parentId={{key}}&&level=1`
							// },
							// {
							// 	label: '持卡人手机号',
							// 	labelWidth: '128',
							// 	prop: 'accountMobile',
							// 	maxlength: 11,
							// 	span: 8
							// },
							// {
							// 	label: '持卡人身份证号',
							// 	labelWidth: '130',
							// 	prop: 'accountIdNum',
							// 	maxlength: 23,
							// 	span: 8
							// }
						]
					},
					{
						label: '店铺首页banner',
						prop: 'group8',
						display: true,
						column: [
							{
								label: 'banner图片',
								formslot: true,
								prop: 'banner',
								row: true,
								span: 24
							},
							{
								label: '店铺描述',
								prop: 'storeDesc',
								type: 'textarea',
								maxlength:100,
								showWordLimit: true,
								minRow: 2,
								row: true,
								span: 12
							}
						]
					},
					{
						label: '店铺状态',
						icon: 'el-icon-info',
						prop: 'group9',
						display: true,
						column: [
							{
								label: '店铺状态',
								prop: 'storeStatus',
								type: 'select',
								dicData: Dict.STORE_STATUS_TYPE,
								span: 8,
								row: true
							},
							{
								label: '拒绝理由',
								prop: 'violationReseaon',
								type: 'textarea',
								display: false,
								span: 8,
								row: true
							}
						]
					},
					{
						label: '店铺管理',
						icon: 'el-icon-info',
						prop: 'group10',
						display: true,
						column: [
							{
								label: '商品不可上架时间段',
								prop: 'noTime',
								labelWidth: 180,
								formslot: true,
								span: 12,
								row: true
							},
							{
								label: '不可参加营销活动时间段',
								prop: 'noActivity',
								labelWidth: 180,
								formslot: true,
								span: 12,
								row: true
							}
						]
					}
				]
			},
			signOptions: [],
			goodsClassIdsOptions: [],
			goodsClassIdsValue: [],
			props1: {
				label: 'name',
				id: 'id',
				children: 'childrenNodes',
			},
			propsClass: {
				label: 'className',
				id: 'id',
				children: 'childrenNodes',
			},
			mineStatus: [],
			signMineStatusValue: [],
			fourLevel: [],
			goodsClassLevel: [],
			organizationSelectData: [],
			
		};
	},
	watch: {
		dialogFormVisible() {
			getListTree().then(res => {
				if (res.data.code == 200) {
					// this.obj.signingAreas
					this.signOptions = res.data.data;
					this.option.group[1].column[13].dicData = res.data.data;
					if (this.isView) {
						//查看店铺信息时，可见区域禁选
						this.signOptions.forEach(item => {
							item.disabled = true; //可选
							item.childrenNodes.forEach(obj => {
								obj.disabled = true; //可选
								obj.childrenNodes.forEach(nodes => {
									nodes.disabled = true; //可选
									nodes.childrenNodes.forEach(child=>{
										child.disabled = true; //可选
									})
								});
							});
						});
					}
				}
			});
			listTreeByUserOrganization().then(res => {
				if (res.data.code == 200) {
					let data =[]
					res.data.data.forEach(item => {
						if(item.isSelect){
							data.push(item.id)
						}
						item.childrenNodes.forEach(obj => {
							if(obj.isSelect){
								data.push(obj.id)
							}
							obj.childrenNodes.forEach(nodes => {
								if(nodes.isSelect){
									data.push(nodes.id)
								}
								nodes.childrenNodes.forEach(child=>{
									if(child.isSelect){
										data.push(child.id)
									}
								})
							});
						});
					});	
					console.log('可选 data')
					console.log(data)
					this.organizationSelectData = data
				}
			});
			if (this.dialogFormVisible) {
				getMapAllGoodsClass({classLevel:2}).then(res => {
					if (res.data.code == 200) {
						this.goodsClassLevel = res.data.data
					}
				});
				getOrganizationMapByLevel({level:4}).then(res => {
					if (res.data.code == 200) {
						this.fourLevel = res.data.data;
						this.getStoreDetail(this.storeId);
					}
				});
				//支付渠道
				// getAllChanelMapList().then(res => {
				// 	if (res.data.code == 200) {
				// 		// this.option.group[1].column[21].dicData = res.data.data;
				// 	}
				// });

			}else{
				console.log("清除表单")
				this.$refs.signTree.setCheckedKeys([]);
				this.$refs.goodsClassTree.setCheckedKeys([]);
				this.$nextTick(() => {
					this.$refs['form'].resetForm();
					this.$refs['form'].clearValidate();
				});
			}
			this.$forceUpdate();
		},
		storeId(){
			console.log(this.storeId)
			if(this.storeId){
				this.option.group[1].column[0].disabled=true
			}else{
				this.option.group[1].column[0].disabled=false
			}
		},
		isView() {
			console.log(this.isView)
			if (this.isView) {
				this.option.submitBtn = false;
				//查看店铺信息时，可见区域禁选
				this.signOptions.forEach(item => {
					item.disabled = true; //可选
					item.childrenNodes.forEach(obj => {
						obj.disabled = true; //可选
						obj.childrenNodes.forEach(nodes => {
							nodes.disabled = true; //可选
							nodes.childrenNodes.forEach(child=>{
								child.disabled = true; //可选
							})
						});
					});
				});
			} else {
				this.option.submitBtn = true;
			}
		},
		'obj.storeStatus'() {
			if (this.obj.storeStatus) {
				console.log(this.obj.storeStatus);
				if (this.obj.storeStatus == -1) {
					this.option.group[9].column[1].display = true;
				} else {
					this.option.group[9].column[1].display = false;
				}
			}
		},
		'obj.validity'() {
			if (this.obj.validity) {
				console.log('obj.validity', this.obj.validity);
			}
		},
		'obj.acTime'(val) {
			if (val) {
				let beginTime = val[0];
				let endTime = val[1];
				// let nowDate=new Date().toLocaleDateString().replace(/\//g, "-")
				// if(new Date(beginTime) < new Date(nowDate)) {
				// 	this.obj.acTime =''
				// 	return (this.$message({
				// 		type: "error",
				// 		message: "开始时间不能小于当前时间"
				// 	}))
				// }
				// if(new Date(endTime) < new Date(nowDate)) {
				// 	this.obj.acTime=''
				// 	return (this.$message({
				// 		type: "error",
				// 		message: "结束时间不能小于当前时间"
				// 	}))
				// }
				if (beginTime > endTime && beginTime && endTime) {
					this.$message({
						type: 'error',
						message: '结束时间不能小于开始时间'
					});
					this.obj.acTime = '';
				}
				this.obj.businessTerm = beginTime + ',' + endTime;
			}
		},
		'obj.cycleType'() {
			console.log('this.obj.cycleType', this.obj.cycleType);
			if (this.obj.cycleType === 0) {
				//月结
				// this.obj.monthsOrWeeks=''
				// this.obj.day=''
				this.option.group[1].column[9].display = true; //几月
				this.option.group[1].column[10].display = true; //几号
				this.option.group[1].column[11].display = false; //几周
				this.option.group[1].column[12].display = false; //周几
			}else if(this.obj.cycleType === 1) {//单周
				this.$notify({
					showClose: true,
					message: '周结：每月1日至当月7日的完结订单， 于当月的10日前完成完结订单核对，并在甲方规定的付款日将款项结算给乙方，遇国家法定节假日，结算及付款期间做相应顺延。每月8日至当月15日的完结订单， 于当月的18日前完成完结订单核对，并在甲方规定的付款日将款项结算给乙方，遇国家法定节假日，结算及付款期间做相应顺延。每月24日至当月30日或31日的完结订单， 于下月的3日前完成完结订单核对，并在甲方规定的付款日将款项结算给乙方，遇国家法定节假日，结算及付款期间做相应顺延。' ,
					type: 'success',
				});
				this.option.group[1].column[9].display = false; //几月
				this.option.group[1].column[10].display = false; //几号
				this.option.group[1].column[11].display = false; //几周
				this.option.group[1].column[12].display = false; //周几
			}else if(this.obj.cycleType === 2) {//双周
				this.$notify({
					showClose: true,
					message: '双周结：每月1日至当月15日的完结订单， 于当月的18日前完成完结订单核对，并在甲方规定的付款日将款项结算给乙方，遇国家法定节假日，结算及付款期间做相应顺延。每月16日至当月30日或31日的完结订单， 于下月的3日前完成完结订单核对，并在甲方规定的付款日将款项结算给乙方，遇国家法定节假日，结算及付款期间做相应顺延。',
					type: 'success',
				});
				this.option.group[1].column[9].display = false; //几月
				this.option.group[1].column[10].display = false; //几号
				this.option.group[1].column[11].display = false; //几周
				this.option.group[1].column[12].display = false; //周几
			}
		},
		'obj.signingAreas'(ids) {
			if (ids) {
				console.log(ids);
				console.log(this.signOptions);
				this.getIds(ids)
			}
		}
	},
	components: {
		selFile
	},
	methods: {
		showBigPic(img,name){
			this.innerVisible = true;
			this.workImg.imgUrl = img
			this.workImg.name = name
		},
		deleteImg(){
			this.obj.operateLicenseImg = ''
		},
		deleteImgOne(){
			this.obj.otherOne = ''
		},
		deleteImgTwo(){
			this.obj.otherTwo = ''
		},
		deleteImgThree(){
			this.obj.otherThree = ''
		},
		deleteImgFour(){
			this.obj.otherFour = ''
		},
		deleteImgFive(){
			this.obj.otherFive = ''
		},
		getIds(ids){
			if(this.isAddOption != 1){//新增
				return
			}
			if (this.signOptions.length > 0) {
				this.obj.signingArea = [];
				this.signOptions.forEach(item => {
					if (item.id == ids) {
						this.obj.signingArea.push(item.id);
					} else {
						item.childrenNodes.forEach(obj => {
							if (obj.id == ids) {
								this.obj.signingArea = [];
								this.obj.signingArea.push(item.id);
								this.obj.signingArea.push(obj.id);
							} else {
								obj.childrenNodes.forEach(nodes => {
									if (nodes.id == ids) {
										this.obj.signingArea = [];
										this.obj.signingArea.push(item.id);
										this.obj.signingArea.push(obj.id);
										this.obj.signingArea.push(nodes.id);
									}else{
										nodes.childrenNodes.forEach(child=>{
											if (child.id == ids){
												this.obj.signingArea = [];
												this.obj.signingArea.push(item.id);
												this.obj.signingArea.push(obj.id);
												this.obj.signingArea.push(nodes.id);
												this.obj.signingArea.push(child.id);
											}

										})
									}
								});
							}
						});
					}
				});
				console.log(this.obj.signingArea);
				this.setoperatingAreas()
			}
		},
		setoperatingAreas(){
			if(this.isAddOption == 1){//新增
				console.log('清除')
				this.$nextTick(()=>{
					this.$refs.signTree.setCheckedKeys([]);
					this.obj.operatingAreas=[]
				})


				// this.signOptions.forEach(item => {
				// 	item.disabled = false; //可选
				// 	item.childrenNodes.forEach(obj => {
				// 		obj.disabled = false; //可选
				// 		obj.childrenNodes.forEach(nodes => {
				// 			nodes.disabled = false; //可选
				// 			nodes.childrenNodes.forEach(child=>{
				// 				child.disabled = false; //可选

				// 			})
				// 		});
				// 	});
				// });
			}
			this.signMineStatusValue=[]
			let option = this.signOptions;
			this.signOptions = [];
			if (this.obj.signingArea.length == 1&&!this.isView) {
				option.forEach(item => {
					if (item.id == this.obj.signingArea[0]) {
						item.disabled = false; //可选
						item.childrenNodes.forEach(obj => {
							obj.disabled = false; //可选
							obj.childrenNodes.forEach(nodes => {
								nodes.disabled = false; //可选
								nodes.childrenNodes.forEach(child=>{
									child.disabled = false; //可选
								})
							});
						});
					} else {
						item.disabled = true; //不可选
						item.childrenNodes.forEach(obj => {
							obj.disabled = true; //不可选
							obj.childrenNodes.forEach(nodes => {
								nodes.disabled = true; //不可选
								nodes.childrenNodes.forEach(child=>{
									child.disabled = true; //可选
								})
							});
						});
					}
				});
			} else if (this.obj.signingArea.length == 2&&!this.isView) {
				option.forEach(item => {
					if (item.id == this.obj.signingArea[0]) {
						item.disabled = false; //可选
						item.childrenNodes.forEach(obj => {
							if (obj.id == this.obj.signingArea[1]) {
								obj.disabled = false; //可选
								obj.childrenNodes.forEach(nodes => {
									nodes.disabled = false; //可选
									nodes.childrenNodes.forEach(child=>{
										child.disabled = false; //可选
									})
								});
							} else {
								obj.disabled = true; //可选
								obj.childrenNodes.forEach(nodes => {
									nodes.disabled = true; //不可选
									nodes.childrenNodes.forEach(child=>{
										child.disabled = true; //可选
									})
								});
							}
						});
					} else {
						item.disabled = true; //不可选
						item.childrenNodes.forEach(obj => {
							obj.disabled = true; //不可选
							obj.childrenNodes.forEach(nodes => {
								nodes.disabled = true; //不可选
								nodes.childrenNodes.forEach(child=>{
									child.disabled = true; //可选
								})
							});
						});
					}
				});
			} else if (this.obj.signingArea.length == 3&&!this.isView) {
				option.forEach(item => {
					if (item.id == this.obj.signingArea[0]) {
						item.disabled = false; //可选
						item.childrenNodes.forEach(obj => {
							if (obj.id == this.obj.signingArea[1]) {
								obj.disabled = false; //可选
								obj.childrenNodes.forEach(nodes => {
									if (nodes.id == this.obj.signingArea[2]) {
										nodes.disabled = false; //可选
										nodes.childrenNodes.forEach(child=>{
											child.disabled = false; //可选
										})
									} else {
										nodes.disabled = true; //不可选
										nodes.childrenNodes.forEach(child=>{
											child.disabled = true; //可选
										})
									}
								});
							} else {
								obj.disabled = true; //可选
								obj.childrenNodes.forEach(nodes => {
									nodes.disabled = true; //不可选
									nodes.childrenNodes.forEach(child=>{
										child.disabled = true; //可选
									})
								});
							}
						});
					} else {
						item.disabled = true; //不可选
						item.childrenNodes.forEach(obj => {
							obj.disabled = true; //不可选
							obj.childrenNodes.forEach(nodes => {
								nodes.disabled = true; //不可选
								nodes.childrenNodes.forEach(child=>{
									child.disabled = true; //可选
								})
							});
						});
					}
				});
			}else if (this.obj.signingArea.length == 4&&!this.isView) {
				option.forEach(item => {
					if (item.id == this.obj.signingArea[0]) {
						item.disabled = false; //可选
						item.childrenNodes.forEach(obj => {
							if (obj.id == this.obj.signingArea[1]) {
								obj.disabled = false; //可选
								obj.childrenNodes.forEach(nodes => {
									if (nodes.id == this.obj.signingArea[2]) {
										nodes.disabled = false; //可选
										nodes.childrenNodes.forEach(child=>{
											if (child.id == this.obj.signingArea[3]) {
												child.disabled = false; //可选
											}else{
												child.disabled = true; //不可选
											}

										})
									} else {
										nodes.disabled = true; //不可选
										nodes.childrenNodes.forEach(child=>{
											child.disabled = true; //可选
										})
									}
								});
							} else {
								obj.disabled = true; //可选
								obj.childrenNodes.forEach(nodes => {
									nodes.disabled = true; //不可选
									nodes.childrenNodes.forEach(child=>{
										child.disabled = true; //可选
									})
								});
							}
						});
					} else {
						item.disabled = true; //不可选
						item.childrenNodes.forEach(obj => {
							obj.disabled = true; //不可选
							obj.childrenNodes.forEach(nodes => {
								nodes.disabled = true; //不可选
								nodes.childrenNodes.forEach(child=>{
									child.disabled = true; //可选
								})
							});
						});
					}
				});
			}
			this.$nextTick(()=>{
				this.signOptions = option;
			})

		},
		clearnoActivity(e) {
			console.log(e);
			if (e) {
				this.obj.goodsNotActivityBeginTime = this.obj.noActivity[0].substring(0, 11) || '';
				this.obj.goodsNotActivityEndTime = this.obj.noActivity[1].substring(0, 11) || '';
			} else {
				this.obj.noActivity = [];
				this.obj.goodsNotActivityBeginTime = '';
				this.obj.goodsNotActivityEndTime = '';
			}
		},
		clearnoTime(e) {
			console.log(e);
			if (e) {
				this.obj.goodsNotAvailableBeginTime = this.obj.noTime[0].substring(0, 11) || '';
				this.obj.goodsNotAvailableEndTime = this.obj.noTime[1].substring(0, 11) || '';
			} else {
				this.obj.noTime = [];
				this.obj.goodsNotAvailableBeginTime = '';
				this.obj.goodsNotAvailableEndTime = '';
			}
		},
		//可见区域选择事件
		goodsClassIdsCheckChange() {

			console.log('goodsClassIdsCheckChange');
				let res = this.$refs.goodsClassTree.getCheckedNodes();
				let res1 = this.$refs.goodsClassTree.getHalfCheckedNodes();
				console.log(res)
				console.log(res1)
				let arrLabel = [];
				let arr = [];
				let ids = [];
				res1.forEach((item) => {
					ids.push(item.id);
				});
				res.forEach((item) => {
					ids.push(item.id);
					arrLabel.push(item.className);
					arr.push(item);
				});
				this.goodsClassIdsValue = arr;
				this.obj.goodsClassIdsLabel = arrLabel;
				this.obj.goodsClassIds = ids;
				console.log(this.goodsClassIdsValue)
				console.log(this.obj.goodsClassIdsLabel)
				console.log(this.obj.goodsClassIds)
		},
		//可见区域选择事件
		signHandleCheckChange() {
			console.log('signHandleCheckChange');
			if (this.obj.signingAreas) {
				let res = this.$refs.signTree.getCheckedNodes();
				let res1 = this.$refs.signTree.getHalfCheckedNodes();
				let arrLabel = [];
				let arr = [];
				let ids = [];
				res1.forEach((item) => {
					ids.push(item.id);
				});
				res.forEach((item) => {
					ids.push(item.id);
					arrLabel.push(item.name);
					arr.push(item);
				});
				this.signMineStatusValue = arr;
				this.obj.operatingAreas = arrLabel;
				this.obj.operatingArea = ids;
			} else {
				this.$refs.signTree.setCheckedKeys([]);
				this.obj.operatingAreas = [];
				this.obj.operatingArea = '';
				this.signMineStatusValue = [];
				this.$message.error('请先选择签约区域');
			}
		},
		//删除已选中的所有的
		signRemove(val) {
			console.log(val)
			this.obj.operatingAreas = [];
			this.$refs.signTree.setChecked(val, false);
			let arr = this.$refs.signTree.getCheckedNodes();
			for (let i in arr) {
				this.obj.operatingAreas.push(arr[i].name);
			}
		},
		//删除已选中的所有的
		goodsClassRemove(val) {
			console.log(val)
			this.obj.goodsClassIdsLabel = [];
			this.$refs.goodsClassTree.setChecked(val, false);
			let arr = this.$refs.goodsClassTree.getCheckedNodes();
			for (let i in arr) {
				this.obj.goodsClassIdsLabel.push(arr[i].name);
			}
		},
		storeLogoUrlSuccess(res) {
			if (res.code == 200) {
				this.obj.storeLogoUrl = res.data.src;
			} else {
				this.$message.error(res.message);
			}
			console.log(this.obj.storeLogoUrl);
		},
		beforeStoreLogoUrlUpload(file) {
			console.log(file);
			const isJPG = file.type === 'image/jpeg' || 'image/png';
			const isLt2M = file.size / 1024 / 1024 < 2;
			if (!isJPG) {
				this.$message.error('上传图片只能是 JPG/PNG 格式!');
			}
			if (!isLt2M) {
				this.$message.error('上传图片大小不能超过 2MB!');
			}
			this.headers['Authorization'] = getToken();
			return isJPG && isLt2M;
		},
		//营业执照号
		businessLicenseSuccess(res) {
			if (res.code == 200) {
				this.obj.businessLicense = res.data.src;
				this.$refs.form.validate(res=>{
					console.log(res)
				})
			} else {
				this.$message.error(res.message);
			}
		},
		//营业许可证
		operateLicenseImgSuccess(res) {
			if (res.code == 200) {
				this.obj.operateLicenseImg = res.data.src;
			} else {
				this.$message.error(res.message);
			}
		},
		//身份证正面
		frontcardImgSuccess(res) {
			if (res.code == 200) {
				this.obj.frontcardImg = res.data.src;
				this.$refs.form.validate(res=>{
					console.log(res)
				})
			} else {
				this.$message.error(res.message);
			}
		},
		//身份证反面
		backcardImgSuccess(res) {
			if (res.code == 200) {
				this.obj.backcardImg = res.data.src;
				this.$refs.form.validate(res=>{
					console.log(res)
				})
			} else {
				this.$message.error(res.message);
			}
		},
		//其他1
		otherOneImgSuccess(res) {
			if (res.code == 200) {
				this.obj.otherOne = res.data.src;
			} else {
				this.$message.error(res.message);
			}
			console.log(this.obj)
		},
		//其他2
		otherTwoImgSuccess(res) {
			if (res.code == 200) {
				this.obj.otherTwo = res.data.src;
			} else {
				this.$message.error(res.message);
			}
			console.log(this.obj)
		},
		//其他3
		otherThreeImgSuccess(res) {
			if (res.code == 200) {
				this.obj.otherThree = res.data.src;
			} else {
				this.$message.error(res.message);
			}
			console.log(this.obj)
		},
		//其他4
		otherFourImgSuccess(res) {
			if (res.code == 200) {
				this.obj.otherFour = res.data.src;
			} else {
				this.$message.error(res.message);
			}
			console.log(this.obj)
		},
		//其他5
		otherFiveImgSuccess(res) {
			if (res.code == 200) {
				this.obj.otherFive = res.data.src;
			} else {
				this.$message.error(res.message);
			}
			console.log(this.obj)
		},
		//获取店铺详情函数
		async getStoreDetail(id) {
			//获取商品分类树
			this.getGoodsClassTree();
			//新增
			if (id == undefined || id == '') {
				//新增店铺
				this.isAddOption = 1;
				this.option.group[0].display=false
				// let date = new Date();
				this.obj.registerTime = onlyDateFormat(new Date());
				this.option.group[1].column[13].disabled = false; //签约区域
				this.option.group[1].column[15].display = false; //周几
				this.option.group[1].column[16].display = false; //周几
				// this.option.group[0].column[13].display=true
				// this.option.group[0].column[16].display=true
				this.option.group[1].column[20].display = true;
				this.option.group[2].display = false;
				this.option.group[3].display = false;
				this.option.group[4].display = false;
				// this.option.group[6].display = false;
				this.option.group[8].display = false;
				this.option.group[9].display = false;
				this.option.group[10].display = false;
				return false;
			} else {
				//编辑店铺
				this.option.group[0].display=true
				this.option.group[1].column[13].disabled = true; //签约区域
				this.option.group[1].column[15].display = true; //周几
				this.option.group[1].column[16].display = true; //周几
				// this.option.group[0].column[13].display=false
				// this.option.group[0].column[16].display=false
				this.option.group[1].column[20].display = false;
				this.option.group[2].display = true;
				this.option.group[3].display = true;
				this.option.group[4].display = true;
				this.option.group[5].display = true;
				// this.option.group[6].display = true;
				this.option.group[8].display = true;
				this.option.group[9].display = true;
				this.option.group[10].display = true;
				this.isAddOption = 0;
			}
			await getStoreDetail(id).then(res => {
				this.obj = {};
				this.obj = res.data.data;
				console.log(this.option.group[1].column[8])
				//结算周期
				if(res.data.data.newSettlementCycle){
					this.option.group[1].column[8].tip = '新周期'+res.data.data.newSettlementCycle + '(本周期按照老周期结算)';
				}
				this.obj.signingArea = res.data.data.signingArea.split(',');
				this.obj.operatingArea = res.data.data.operatingArea.split(',');
				this.obj.goodsClassIds = res.data.data.goodsClassIds.split(',');
				this.goodsClassIdsValue = [];
				this.obj.goodsClassIds.forEach(item => {
					if (this.goodsClassLevel[item]) {
						this.goodsClassIdsValue.push(item);
					}
				});
				this.signMineStatusValue = [];
				this.obj.signingAreas = Number(this.obj.signingArea[this.obj.signingArea.length - 1]);
				this.obj.operatingAreas = [];
				this.obj.operatingArea.forEach(item => {
					if (this.fourLevel[Number(item)]) {
						this.signMineStatusValue.push(Number(item));
					}
				});

				setTimeout(()=>{
					if(this.signMineStatusValue.length>0){
						this.$refs.signTree.setCheckedKeys(this.signMineStatusValue);
					}
					if(this.goodsClassIdsValue.length>0){
						this.$refs.goodsClassTree.setCheckedKeys(this.goodsClassIdsValue);
					}
				},1000)

				getStoreBanner(id).then(res => {
					this.obj.banner = res.data.data;
					res.data.data.forEach(item => {
						this.srcList.push(item.imgUrl);
					});
				});
				this.obj.validity = res.data.data.validity.substring(0, 11);
				this.obj.registerTime = res.data.data.registerTime.substring(0, 11);

				setTimeout(()=>{
					let node1 = this.$refs.signTree.getCheckedNodes();
					if(node1.length>0){
						node1.forEach(n1=>{
							this.obj.operatingAreas.push(n1.name)
						})
					}
					this.setoperatingAreas()
					let node2 = this.$refs.goodsClassTree.getCheckedNodes();
					this.obj.goodsClassIdsLabel= []
					if(node2.length>0){
						node2.forEach(n2=>{
							this.obj.goodsClassIdsLabel.push(n2.className)
						})
					}
					this.$nextTick(() => {
						this.$refs['form'].clearValidate();
					});
				},3000)

				this.obj.noTime = [];
				this.obj.noActivity = [];
				if (this.obj.goodsNotAvailableBeginTime) {
					this.obj.noTime.push(this.obj.goodsNotAvailableBeginTime.substring(0, 11));
					this.obj.noTime.push(this.obj.goodsNotAvailableEndTime.substring(0, 11));
				}
				if (this.obj.goodsNotActivityBeginTime) {
					this.obj.noActivity.push(this.obj.goodsNotActivityBeginTime.substring(0, 11));
					this.obj.noActivity.push(this.obj.goodsNotActivityEndTime.substring(0, 11));
				}


				//获取寄件人省市地址
				getParentAndGrandInfoById(this.obj.companyAreaId).then(
					res => {
						var data = res.data.data;
						this.obj.companyProvince = data.gId;
						this.obj.companyCity = data.pId;
					},
					error => {
						console.log(error);
					}
				);

				if (this.obj.businessTerm.length > 0) {
					this.obj.acTime = [];
					let time = this.obj.businessTerm.split(',');
					this.obj.acTime[0] = time[0];
					this.obj.acTime[1] = time[1];
				}
				
				console.log(this.obj);
			});
		},
		//获取地址
		getParentAndGrandInfoById(id) {
			return getParentAndGrandInfoById(id);
		},
		//获取银行所在城市
		getParentInfoById(id) {
			return getParentInfoById(id);
		},
		//店铺详情弹框提交
		submit(loading, done) {
			this.loading = true;
			console.log(this.obj)
			if(this.obj.cycleType==1 || this.obj.cycleType==2){//周结
				this.obj.monthsOrWeeks = ''
				this.obj.day = ''
			}
			setTimeout(()=>{
				done();
			},1000)
			if(this.organizationSelectData.indexOf(this.obj.signingAreas)==-1){
				this.$message({
					type: 'warning',
					message: '所选签约区域超出范围，请重新选择'
				});
				return;
			}
			if (this.isAddOption == 1) {
				this.$emit('addOption', this.obj);
			} else {
				this.$emit('callBack', this.obj);
			}
			if(!this.dialogFormVisible){
				this.$nextTick(() => {
					this.$refs['form'].resetForm();
					this.$refs['form'].clearValidate();
				});
			}
		},
		closeDrawer() {
			this.$emit('closeDrawer');
			this.$nextTick(() => {
				this.$refs['form'].resetForm();
			});
			this.$nextTick(() => {
				this.$refs['form'].clearValidate();
			});
		},
		uploadbtn(imgType) {
			if (this.isView) {
				this.imgType = imgType;
				//上传图片
				this.$refs.selFile.open();
			}
		},
		// selFileCallBack(data) {
		// 	//选中图片传回的数据
		// 	//最多上传5张照片
		// 	if (data.length > 1) {
		// 		this.$message({
		// 			type: 'warning',
		// 			message: '最多可上传1张图片'
		// 		});
		// 		if (this.imgType == 1) {
		// 			this.obj.businessLicense = [];
		// 			this.obj.businessLicense = data[0];
		// 		} else if (this.imgType == 2) {
		// 			this.obj.operateLicenseImg = [];
		// 			this.obj.operateLicenseImg = data[0];
		// 		} else if (this.imgType == 3) {
		// 			this.obj.frontcardImg = [];
		// 			this.obj.frontcardImg = data[0];
		// 		} else if (this.imgType == 4) {
		// 			this.obj.backcardImg = [];
		// 			this.obj.backcardImg = data[0];
		// 		} else if (this.imgType == 5) {
		// 			this.obj.orthersImg = [];
		// 			this.obj.orthersImg = data[0];
		// 		}
		// 	} else {
		// 		if (this.imgType == 1) {
		// 			this.obj.businessLicense = data[0];
		// 		} else if (this.imgType == 2) {
		// 			this.obj.operateLicenseImg = data[0];
		// 		} else if (this.imgType == 3) {
		// 			this.obj.frontcardImg = data[0];
		// 		} else if (this.imgType == 4) {
		// 			this.obj.backcardImg = data[0];
		// 		} else if (this.imgType == 5) {
		// 			this.obj.orthersImg = data[0];
		// 		}
		// 	}
		// },
		//获取商品分类
		getGoodsClassTree() {
			getClassTree().then(res => {
				if (res.status == 200) {
					if (res.data.code == 200) {
						// 四级分类不可选,所以不展示
						res.data.data.forEach(item=>{
							if(item.childrenNodes.length>0) {
								item.childrenNodes.forEach(ite=>{
									if(ite.childrenNodes.length>0) {
										ite.childrenNodes.forEach(it=>{
											it.childrenNodes=[]
										})
									}
								})
							}
						})
						this.goodsClassIdsOptions = res.data.data;
						if(this.isView){
							this.goodsClassIdsOptions.forEach(item=>{
								if(item.childrenNodes.length>0) {
									item.disabled = true
									item.childrenNodes.forEach(ite=>{
										if(ite.childrenNodes.length>0) {
											ite.disabled = true
											ite.childrenNodes.forEach(it=>{
												it.disabled = true
												it.childrenNodes=[]
											})
										}
									})
								}
							})
						}
					} else {
						this.$message.error(res.data.message);
					}
				}
			});
		}
	}
};
</script>

<style scoped lang="scss">
.el-range-separator {
	display: flex !important;
	align-items: center !important;
}

.avatar-uploader {
	width: 100%;
	height: auto;
	margin-bottom: 20px;
	/* border: 1px dashed #d9d9d9; */
	border-radius: 6px;
	cursor: pointer;
	position: relative;
	overflow: hidden;
}
.avatar-uploader:hover {
	border-color: #F39800;
}
.el-upload--picture-card{
	width: 100% !important;
	height: 100% !important;
	min-height: 96px !important;
	min-width: 96px !important;
}
.avatar-uploader.pictureCard {
	border: 0;
	width: auto;
	min-width: 96px;
	height: 100%;
}
.avatar-uploader .avatar {
	width: 100%;
	height: 100%;
}
.others{
	display: flex;
	.other-item{
		display: block;
	}
}
/* .avatar-uploader .el-upload {
	border: 1px dashed #d9d9d9;
	border-radius: 6px;
	cursor: pointer;
	position: relative;
	overflow: hidden;
}

.avatar-uploader .el-upload:hover {
	border-color: #F39800;
} */

.avatar-uploader-icon {
	font-size: 28px;
	color: #8c939d;
	width: 100%;
	height: 100%;
	min-height: 96px;
	min-width: 96px;
	/* line-height: 146px; */
	text-align: center;
}

.avatar {
	width: 100%;
	height: 100%;
	min-height: 96px;
	min-width: 96px;
	display: block;
}
.upload {
	display: flex;
	justify-content: flex-start;
	align-items: center;
}
.business-license{
	position: relative;
	span{
		position: absolute;
		right:0px;
		top:0px;
		width: 15px;
		height: 15px;
		font-size: 20px;
		color:#f39800;
	}
}
.el-upload-list--picture-card .el-upload-list__item {
	margin-right: 40px !important;
}
.el-input--suffix .el-input__inner{
	padding-right:90px !important;
}
/deep/ .el-tag.el-tag--info .el-tag__close {
	color: #909399;
	display: none!important;
}
</style>
